home *** CD-ROM | disk | FTP | other *** search
/ SGI Enlighten DSM 3.1 / SGI EnlightenDSM 3.1.iso / DEC3240 / COMMON.Z / COMMON / bin / set_nis_client < prev    next >
Text File  |  1999-04-16  |  2KB  |  111 lines

  1. #!/bin/sh
  2. #
  3. # Copyright (c) 1990-1999 Enlighten Software Solutions, Inc.
  4. #
  5. # Check arguments: <domain> <master> <master IP> <start_at_boot>
  6. if [ $# -ne 4 ]
  7. then
  8.      exit 1
  9. fi
  10.  
  11. DOMAIN=$1
  12. MASTER=$2
  13. MASTERIP=$3
  14. STARTATBOOT=$4
  15.  
  16. # Initialize variables
  17. TMP=/tmp/nissetup.client.$$
  18. HOSTS=/etc/hosts
  19. RCCONF=/etc/rc.config
  20. ECHO=/bin/echo
  21. RCMGR=/usr/sbin/rcmgr
  22. NISSETUP=/usr/sbin/nissetup
  23.  
  24. # Check if NIS is already configured
  25. prev_conf=`$RCMGR get NIS_CONF`
  26.  
  27. # Check to make sure nissetup won't complain about
  28. # system configuration
  29. if [ \! -w "$RCCONF" ]
  30. then
  31.      exit 2
  32. fi
  33.     
  34. hname=`hostname`
  35. if [ $? -ne 0 ] 
  36. then
  37.      exit 3
  38. fi
  39.  
  40. if [ "$prev_conf" = "YES" ]
  41. then
  42.      exit 4
  43. fi
  44.  
  45. # Yes, we want to continue 
  46. $ECHO "C" > $TMP
  47.  
  48. # Press ENTER twice
  49. $ECHO "\n" >> $TMP
  50.    
  51. # The host's NIS domain name
  52. $ECHO $DOMAIN >> $TMP
  53. # ... yes, this is the correct NIS domain name
  54. $ECHO "y" >> $TMP
  55.  
  56. # This is going to be a NIS client
  57. $ECHO "3" >> $TMP
  58.  
  59. # Yes, we want to continue 
  60. $ECHO "C" >> $TMP
  61.  
  62. # Use the -s security option for ypbind
  63. $ECHO "y" >> $TMP
  64.  
  65. # Use the -S security option for ypbind
  66. $ECHO "y" >> $TMP
  67.  
  68. # Check to make sure the server name is a correct NIS server name
  69. sed "s/#.*//" $HOSTS > $HOSTS.tmp
  70. good=`egrep "[     ]$MASTER([     \.]|$)" $HOSTS.tmp`
  71. if [ -n "$good" ]
  72. then
  73.    short=`echo $hname | sed 's/\..*//'`
  74.    if [ "$MASTER" = "$hname" ]  || [ "$MASTER" = "$short" ]
  75.    then
  76.       exit 5
  77.    fi
  78. else
  79. # add the entry to $HOSTS instead of exiting.
  80. # we have the IP address in renldc already
  81. # we'll assume the lookup on GUI host produces the right one! :)
  82.    echo "$MASTERIP  $MASTER" >> $HOSTS
  83. fi
  84.  
  85. # Enter (just one) authorized server
  86. $ECHO $MASTER >> $TMP
  87. $ECHO "" >> $TMP
  88.  
  89. # Yes, we want to continue 
  90. $ECHO "C" >> $TMP
  91.  
  92. # Disallow all ypset requests
  93. $ECHO "3" >> $TMP
  94.  
  95. # ... yes, this is correct
  96. $ECHO "y" >> $TMP
  97.  
  98. # Use all of the NIS databases served by the NIS server
  99. $ECHO "y" >> $TMP
  100.  
  101. # Start the NIS daemons now
  102. $ECHO "y" >> $TMP
  103.  
  104. # Run the NIS setup utility
  105. cat $TMP | $NISSETUP
  106.  
  107. # Done!
  108. rm $TMP
  109. exit 0
  110.  
  111.